home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / t_os / wstype / source / whelp.c < prev    next >
C/C++ Source or Header  |  1991-10-18  |  6KB  |  275 lines

  1. /***   [whelp.c]
  2. *
  3. *    ヘルプウィンドウ        (C)ささがわ
  4. *
  5. *    For GNU C Compiler (GCC)   Version 1.39
  6. *
  7. ***/
  8.  
  9. #include <mos.h>
  10. #include "graph.h"
  11. #include "window.h"
  12. #include "others.h"
  13.  
  14. #define WH_CAN        1
  15. #define WH_TITLE    2
  16. #define WH_BACK        3
  17. #define WH_NEXT        4
  18. #define WH_OTHER    0
  19.  
  20. extern int    PAL_Black, PAL_Button;
  21. static int    wx, wy;
  22. static int    nPage = 8, Page;
  23. const static char    *help[][8] = {
  24.     {
  25.     /*    "                  40桁                  "    */
  26.         "",
  27.         "       WSType   Version 1.0",
  28.         "",
  29.         "",
  30.         "           補  足  説  明  書",
  31.         "",
  32.         "",
  33.         "  Copyright (C)ささがわ   Aug. 18, 1991 "
  34.     }, {
  35.         "・影付きのウィンドウは特別な扱いに",
  36.         "  なっています  他を操作したい場合は",
  37.         "  それを消してから行ってください",
  38.         "",
  39.         "・ワイド型ファイルセレクタを操作中",
  40.         "  ツリー表示を中断させたい場合は",
  41.         "  マウスの右ボタンをクリックして",
  42.         "  ください                           1/7"
  43.     }, {
  44.         "・警告音のPCMサウンドには",
  45.         "  再生できる音程に限界があります",
  46.         "",
  47.         "・スコープを移動する場合は 画面左上の",
  48.         "  ボタン上で左ボタンを押し 1秒ほど",
  49.         "  待ってからドラッグさせ ボタンから手を",
  50.         "  放してください",
  51.         "                                     2/7"
  52.     }, {
  53.         "《起動時オプション》",
  54.         "  ◆表示方法",
  55.         "    /tabm {0|1}        タブ記号の表示(0)",
  56.         "    /crm {0|1}        改行記号の表示(1)",
  57.         "    /tab {1|2|4|8}             タブ長(8)",
  58.         "    /lg {0~4}                行間隔(2)",
  59.         "    /lc {0|20~500}            横幅(80)",
  60.         "                                     3/7"
  61.     }, {
  62.         "  ◆背景画",
  63.         "    /bg-tiff <ファイル名>          TIFFファイル",
  64.         "    /bg-tile <ファイル名> <番号>     タイリング",
  65.         "    /bg-beta <色番号>           ベタ塗り",
  66.         "",
  67.         "  ◆スクロール",
  68.         "    /scspd {0~4}       スクロール・スピード(2)",
  69.         "                                     4/7"
  70.     }, {
  71.         "  ◆警告音",
  72.         "    /wa-beep                    ビープ音",
  73.         "    /wa-pcm <ファイル名>           pcmサウンド",
  74.         "",
  75.         "  ◆ファイルセレクタ",
  76.         "    /fcap {0|1}       0:小文字 1:大文字",
  77.         "    /fsort {0~3}               ソート方法",
  78.         "                                     5/7"
  79.     }, {
  80.         "    /fwide {0|1}          0:標準 1:ワイド",
  81.         "",
  82.         "  ◆その他",
  83.         "    /m             終了時にMS-DOS画面へ",
  84.         "",
  85.         "    頭に / の付かないものは",
  86.         "              テキストファイル名と見なします",
  87.         "                                     6/7"
  88.     }, {
  89.         "《作者からの一言》",
  90.         "",
  91.         "    その他、質問・要望等がありましたら",
  92.         "    作者までご連絡ください。",
  93.         "    (感想・バグの報告などもお待ち)",
  94.         "    (しています。                )",
  95.         "",
  96.         "                                     7/7"
  97.     }
  98. };
  99.  
  100. static void    Open_window(void);
  101. static int    Where(int, int);
  102. static void    DrawHelp(void);
  103. static void    SUB_page(int);
  104. static int    SUB_page_sub(int);
  105. static void    Indicate(int, int);
  106.  
  107. void WIND_help(void) {
  108.     int        ret = 0;
  109.     
  110.     wx = 152;
  111.     wy = 142;
  112.     {
  113.         struct RECT    a, b;
  114.         
  115.         a.x1 = 319;    a.y1 = 259;
  116.         a.x2 = 320;    a.y2 = 260;
  117.         b.x1 = wx;    b.y1 = wy;
  118.         b.x2 = wx + 335;    b.y2 = wy + 196;
  119.         afterImage(&a, &b);
  120.     }
  121.     
  122.     Page = 0;
  123.     Open_window();
  124.     while (!ret) {
  125.         char    mb;
  126.         int        mx, my;
  127.         
  128.         CLOCK(0);
  129.         if (MOS_rdpos(&mb, &mx, &my), !(mb & 1))
  130.             continue;
  131.         
  132.         switch (Where(mx, my)) {
  133.             case WH_CAN:
  134.                 if (Button(wx + 6, wy + 6, wx + 25, wy + 25))
  135.                     ret = -1;
  136.                 break;
  137.             
  138.             case WH_TITLE:
  139.                 {
  140.                     struct RECT    w, s;
  141.                     
  142.                     s.x1 = 0;    s.y1 = 40;
  143.                     s.x2 = 639;    s.y2 = 463;
  144.                     w.x1 = wx;    w.y1 = wy;
  145.                     w.x2 = wx + 335;    w.y2 = wy + 196;
  146.                     if (dragWindow(mx, my, &w, &s, 0, 0)) {
  147.                         wx = w.x1;    wy = w.y1;
  148.                         MOS_disp(0);
  149.                         EGB_cls(0);
  150.                         MOS_disp(1);
  151.                         Open_window();
  152.                     }
  153.                 }
  154.                 break;
  155.             
  156.             case WH_BACK:    SUB_page(0);    break;
  157.             case WH_NEXT:    SUB_page(1);    break;
  158.             
  159.             default:
  160.                 while (MOS_rdpos(&mb, &mx, &my), mb & 1);
  161.                 break;
  162.         }
  163.     }
  164.     
  165.     return;
  166. }
  167.  
  168. static void Open_window(void) {
  169.     int        a[2] = {4, 4};
  170.     struct opnwin_t    opw;
  171.     
  172.     opw.title = "ヘ ル プ";
  173.     opw.x1 = wx;
  174.     opw.y1 = wy;
  175.     opw.x2 = opw.x1 + 335;
  176.     opw.y2 = opw.y1 + 196;
  177.     opw.shdw = 1;
  178.     opw.canb = 1;
  179.     opw.nopt = 2;
  180.     opw.wopt = a;
  181.     opw.expb = 0;
  182.     opw.ord = 0;
  183.     
  184.     MOS_disp(0);
  185.     drawWindow(&opw);
  186.     Indicate(1, 1);
  187.     DrawHelp();
  188.     MOS_disp(1);
  189. }
  190.  
  191. static int Where(int x, int y) {
  192.     int        ret;
  193.     
  194.     x -= wx;
  195.     y -= wy;
  196.     if (5 < x && x < 26 && 5 < y && y < 26)
  197.         ret = WH_CAN;
  198.     else if (26 < x && x < 256 && 5 < y && y < 26)
  199.         ret = WH_TITLE;
  200.     else if (256 < x && x < 293 && 5 < y && y < 26)
  201.         ret = WH_BACK;
  202.     else if (293 < x && x < 330 && 5 < y && y < 26)
  203.         ret = WH_NEXT;
  204.     else
  205.         ret = WH_OTHER;
  206.     
  207.     return ret;
  208. }
  209.  
  210. static void Indicate(int a, int b) {
  211.     if (a)
  212.         EGB_str("前頁", wx + 259, wy + 23, Page > 0 ? PAL_Black : 7);
  213.     if (b)
  214.         EGB_str("次頁", wx + 296, wy + 23, Page < nPage - 1 ? PAL_Black : 7);
  215. }
  216.  
  217. static void DrawHelp(void) {
  218.     int        i;
  219.     
  220.     EGB_boxf(wx + 8, wy + 29, wx + 327, wy + 188, 7, 7);
  221.     for (i = 0; i < 8; i++)
  222.         EGB_str3(help[Page][i], wx + 8, wy + 46 + i * 20, PAL_Black, 7);
  223. }
  224.  
  225. static void SUB_page(int mode) {
  226.     int        flpush = 1, fllast = 0;
  227.     int        lx, ly, mx, my;
  228.     char    mb;
  229.     
  230.     if (mode && Page >= nPage - 1 || !mode && Page <= 0) {
  231.         while (MOS_rdpos(&mb, &mx, &my), mb & 1);
  232.         return;
  233.     }
  234.     
  235.     lx = wx + (mode ? 294 : 257);
  236.     ly = wy + 6;
  237.     
  238.     EGB_rev(1, lx, ly, lx + 35, ly + 19);
  239.     fllast = SUB_page_sub(mode);
  240.     TIMER_set(30);
  241.     while (MOS_rdpos(&mb, &mx, &my), mb & 1 && !fllast) {
  242.         int        whres;
  243.         
  244.         whres = Where(mx, my) == (mode ? WH_NEXT : WH_BACK);
  245.         if (!whres && flpush || whres && !flpush) {
  246.             EGB_rev(1, lx, ly, lx + 35, ly + 19);
  247.             flpush = !flpush;
  248.         }
  249.         
  250.         if (flpush && TIMER())
  251.             fllast = SUB_page_sub(mode);
  252.     }
  253.     
  254.     MOS_disp(0);
  255.     Indicate(1, 1);
  256.     MOS_disp(1);
  257.     if (fllast)
  258.         while (MOS_rdpos(&mb, &mx, &my), mb & 1);
  259. }
  260.  
  261. static int SUB_page_sub(int mode) {
  262.     int        result = 1;
  263.     
  264.     if (mode && Page < nPage - 1 || !mode && Page > 0) {
  265.         mode ? Page++ : Page--;
  266.         MOS_disp(0);
  267.         DrawHelp();
  268.         Indicate(mode ? 1 : 0, mode ? 0 : 1);
  269.         MOS_disp(1);
  270.         result = 0;
  271.     }
  272.     
  273.     return result;
  274. }
  275.